<?php

/** тама rapatij-cms - begin */
include "auth_init_values.inc";
if (isset($_COOKIE['cms_theme'])){
    $theme = $jquery_ui_themes[ $_COOKIE['cms_theme'] ];
}else{
    $theme = "black-tie";
}
/** тама rapatij-cms - end */

?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8" />
    <base href="http://localhost/cms/vikno.com.cv.ua/admin/"/>
    <title>Система адміністрування</title>
    <script src="../plugin/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="../plugin/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
    <script src="../js/jquery.cookie.js" type="text/javascript"></script>
    <script src="actions.js" type="text/javascript"></script>
    <script src="main.js" type="text/javascript"></script>
    <link rel="stylesheet" href="../plugin/jquery-ui/themes/<?php echo($theme) ?>/jquery-ui.min.css" />
    <link rel="stylesheet" href="style.css" />
    <script src="http://malsup.github.com/jquery.form.js"></script>

    <script type="text/javascript" src="../plugin/tinymce/tinymce.min.js"></script>
</head>
<body>
<?php

session_start();

ini_set("display_errors",1);
error_reporting(E_ALL);

/** check authorisation - begin */
if (isset($_REQUEST['login']) &&
    isset($_REQUEST['pass']) &&
    (trim($_REQUEST['captcha'])==$_SESSION['spec_captcha'])
){

    $login = trim($_REQUEST['login']);
    $pass  = trim($_REQUEST['pass']);

    if (strlen($login)){
        if (strlen($pass)){

            include "../../classes/cms_admin.php";
            $user_auth = new cms_admin();
            $flag = $user_auth->login($login, $pass);
            if ($flag){
                $_SESSION['user_id'] = $flag;
                $_SESSION['spec_captcha'] = false;
            }

        }else{
            $error[] = 'Введіть пароль!';
        }
    }else{
        $error[] = 'Введіть логін!';
    }

}
/** check authorisation - end */

if (isset($_SESSION['user_id'])){
    include_once 'auth_user.php';
}else{
    include_once 'no_auth.php';
}

?>
</body>